Hit Processor


ATT raw Hit processor.

</span>
This notebook shows how the hit processor works.
The Hit processors aim is to parse the raw hit readings from the serial port.

Set modules path first:


In [1]:
import sys
#sys.path.insert(0, '/home/asanso/workspace/att-spyder/att/src/python/')
sys.path.insert(0, 'i:/dev/workspaces/python/att-workspace/att/src/python/')

Let's parse


In [2]:
from hit.process.processor import ATTMatrixHitProcessor
from hit.process.processor import ATTPlainHitProcessor

plainProcessor = ATTPlainHitProcessor()
matProcessor = ATTMatrixHitProcessor()

Parse a Hit with Plain Processor


In [3]:
plainHit = plainProcessor.parse_hit("hit: {0:25 1549:4 2757:4 1392:4 2264:7 1764:7 1942:5 2984:5 r}")
print plainHit


{'sensor_timings': ['0', '1549', '2757', '1392', '2264', '1764', '1942', '2984'], 'raw': 'hit: {0:25 1549:4 2757:4 1392:4 2264:7 1764:7 1942:5 2984:5 r}', 'side': 'r', 'sensor_values': ['25', '4', '4', '4', '7', '7', '5', '5'], 'tstamp': 1459277107.344}

Compute diffs:


In [4]:
plainDiffs = plainProcessor.hit_diffs(plainHit["sensor_timings"])
print plainDiffs


[-1549. -2757. -1392. -2264. -1764. -1942. -2984. -1208.   157.  -715.
  -215.  -393. -1435.  1365.   493.   993.   815.  -227.  -872.  -372.
  -550. -1592.   500.   322.  -720.  -178. -1220. -1042.]

Parse a Hit with Matrix Processor


In [5]:
matHit = matProcessor.parse_hit("hit: {0:25 1549:4 2757:4 1392:4 2264:7 1764:7 1942:5 2984:5 r}")
print matHit


{'sensor_timings': ['0', '1549', '2757', '1392', '2264', '1764', '1942', '2984'], 'raw': 'hit: {0:25 1549:4 2757:4 1392:4 2264:7 1764:7 1942:5 2984:5 r}', 'side': 'r', 'sensor_values': ['25', '4', '4', '4', '7', '7', '5', '5'], 'tstamp': 1459277112.433}

Compute diffs:


In [6]:
matDiffs = matProcessor.hit_diffs((matHit["sensor_timings"]))
print matDiffs


[[    0. -1549. -2757. -1392. -2264. -1764. -1942. -2984.]
 [-1549.     0. -1208.   157.  -715.  -215.  -393. -1435.]
 [-2757. -1208.     0.  1365.   493.   993.   815.  -227.]
 [-1392.   157.  1365.     0.  -872.  -372.  -550. -1592.]
 [-2264.  -715.   493.  -872.     0.   500.   322.  -720.]
 [-1764.  -215.   993.  -372.   500.     0.  -178. -1220.]
 [-1942.  -393.   815.  -550.   322.  -178.     0. -1042.]
 [-2984. -1435.  -227. -1592.  -720. -1220. -1042.     0.]]

In [7]:
matDiffs


Out[7]:
array([[    0., -1549., -2757., -1392., -2264., -1764., -1942., -2984.],
       [-1549.,     0., -1208.,   157.,  -715.,  -215.,  -393., -1435.],
       [-2757., -1208.,     0.,  1365.,   493.,   993.,   815.,  -227.],
       [-1392.,   157.,  1365.,     0.,  -872.,  -372.,  -550., -1592.],
       [-2264.,  -715.,   493.,  -872.,     0.,   500.,   322.,  -720.],
       [-1764.,  -215.,   993.,  -372.,   500.,     0.,  -178., -1220.],
       [-1942.,  -393.,   815.,  -550.,   322.,  -178.,     0., -1042.],
       [-2984., -1435.,  -227., -1592.,  -720., -1220., -1042.,     0.]])

In [ ]: